package com.youzan.cloud.controller;

import com.youzan.cloud.common.dto.AccessToken;
import com.youzan.cloud.common.dto.AuthorizationDto;
import com.youzan.cloud.service.TokenService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author tangsen233
 * @version 1.0
 * @description: 获取token
 * @date 2021/12/13 17:49
 */
@RestController
@RequestMapping("/auth")
@Slf4j
public class TokenController {

    @Autowired
    TokenService tokenService;

     @RequestMapping("/token")
     public AccessToken getToken(AuthorizationDto authorizationDto){
         AccessToken token;
         try {
             token = tokenService.getToken(authorizationDto);
         }catch (Exception e){
             log.error("获取token异常",e);
             throw e;
         }
         return token;
     }
}